home *** CD-ROM | disk | FTP | other *** search
/ The Arsenal Files 6 / The Arsenal Files 6 (Arsenal Computer).ISO / wordpro / vde18f.zip / VMACRO.REF < prev    next >
Text File  |  1995-08-31  |  40KB  |  705 lines

  1.  
  2.                                   VMACRO.REF
  3.                                   ----------
  4.                      Macro Reference for the VDE Editor:
  5.                          version 1.8 (31 Aug 1995)
  6.  
  7.                              (c)1987-95, E. Meyer
  8.  
  9.  
  10.  
  11.  ===============================  CONTENTS  ==================================
  12.  
  13.     (For QUICK START, SYNTAX, GENERAL INFORMATION etc. see the file VDE.DOC)
  14.  
  15.     (For a comprehensive COMMAND REFERENCE, see the file VDE.REF)
  16.  
  17.      8. MACRO INSTRUCTIONS:
  18.           A. Keystrokes and notation
  19.           B. Defining macros
  20.           C. Recording macros
  21.           D. Assigning macros to keys
  22.           E. Macro programming
  23.           F. Examples of useful macros
  24.           G. Adding features: Mail Merge
  25.  
  26.      9. MACRO REFERENCE, alphabetically by topic:
  27.             Autoexec macro, Chaining and calling, Counter variable, Define or 
  28.          record macro, Error handling, Function keys, Function key labels, Key 
  29.          definition files, Labels and jumps, Pause, Tests and loops, Toggle 
  30.          control.
  31.  
  32.     (For use of the VINST installation utility, see the file VINST.REF)
  33.  
  34.  
  35.  ===============================  8. MACROS  =================================
  36.  
  37.                           A. KEYSTROKES AND NOTATION
  38.  
  39.      Essentially, a macro is a sequence of keystrokes representing text and/or 
  40.  VDE commands, which can then be repeated automatically or stored to a key for 
  41.  future use in order to make frequently performed tasks easier.
  42.  
  43.      While this may sound quite straightforward, it is obviously necessary to 
  44.  get such a key sequence EXACTLY correct for the macro to perform as intended; 
  45.  therefore, the representations of macros in this manual present many 
  46.  possibilities for confusion.  First, some basics: the characters "[]" are 
  47.  often used to signify the pressing of a single key, like "[Esc]" -- but they 
  48.  are not used when that key is exhibited as part of a macro or multi-key 
  49.  command, like "Esc&F2".  Also, don't be confused by the fact that a single 
  50.  bracket can also appear as part of certain macro commands, like "Esc~^M]".  
  51.  The character "^" is normally used to indicate control-key combinations, as 
  52.  in "^M" for Ctrl-M; but there are special cases when the character "^" itself 
  53.  needs to be typed, as in "Esc&^F2" or "^K^".
  54.  
  55.      A space will often be used here to separate groups of keystrokes to make 
  56.  a macro easier to read and understand -- but these spaces ARE NOT part of the 
  57.  macro, and should not be typed in if you are trying to define it.  Any spaces 
  58.  that actually ARE part of the macro and SHOULD be typed in are represented by 
  59.  the underline character "_", which is not itself part of any macro here.
  60.  
  61.      Finally, there are occasional differences between the keystrokes you 
  62.  would actually type in order to perform a task, and those that must be typed 
  63.  in order to enter this sequence at the macro definition prompt.  At all VDE 
  64.  string prompts, there are certain control-characters which control the 
  65.  entering of the string itself; for the macro definition command Esc[, this is 
  66.  a somewhat shorter list than for other prompts, but it still includes:
  67.          [Enter] or ^[Enter] -- terminates entry of the string
  68.                       [BkSp] -- deletes the last character entered
  69.                           ^R -- (as 1st key) replays the last macro entered
  70.                           ^P -- enters codes like these in macros
  71.  This means that to include any of these keys AS PART OF THE MACRO ITSELF 
  72.  requires the ^P prefix first.  If you forget this prefix, of course, you will 
  73.  instead see the key perform its function indicated above.
  74.      Throughout this manual, macros are presented as they actually function, 
  75.  since this is easier to understand; that is, they DO NOT include any extra ^P 
  76.  prefixes required for code entry.  If you are trying to enter a macro at the 
  77.  definition prompt, you must remember to use caution with the above control 
  78.  keys!  (See also ^P NESTING, below.)
  79.      It is also important to bear in mind that starting with VDE 1.8, in most 
  80.  cases, the following keys are no longer equivalent:
  81.          [Enter] and ^M (CR)    [BkSp] and ^H     [Esc] and ^[
  82.         ^[Enter] and ^J (LF)    [Tab]  and ^I
  83.  The one case where these keys remain interchangeable is in their use after ^P 
  84.  to embed an ASCII control-code (like ^H, ASCII 08) in the text.  Otherwise, 
  85.  they are related but distinct: [BkSp] is a COMMAND that deletes a character 
  86.  from the text or a prompt input line, while ^H (BS) is a CHARACTER that can 
  87.  be part of the text (where it will cause a backspace when printing) or of a 
  88.  command like ^K^H.  (^H can also be an entirely unrelated command by itself.)  
  89.  [BkSp] will require a ^P prefix to enter into a macro, ^H will not; and so 
  90.  on.  (Any macros from VDE versions prior to 1.8 will need to be redefined 
  91.  with these differences in mind.)
  92.  
  93.      EXAMPLE: Consider the following macro, whose purpose is explained more 
  94.  fully below under EXAMPLES OF USEFUL MACROS:
  95.  
  96.                    ^QS ^X Esc=_] Esc=^M] ^S_^D Esc![
  97.  
  98.  Following the explanations above, be sure you understand why in the middle of 
  99.  defining this macro you must use ^M, not [Enter], and verify that it will 
  100.  involve 17 separate keystrokes, namely:
  101.  
  102.        Macro:  Ctrl-Q S Ctrl-X Esc = Space ] Esc = Ctrl-M ]
  103.                    Ctrl-S Space Ctrl-D Esc ! [
  104.  
  105.  and then, of course, a final [Enter] to terminate the definition.  If you do 
  106.  this correctly, you will see on screen something like this (the underlined 
  107.  letters will be highlighted as control-codes, and the "e" symbol indicating 
  108.  the [Esc] key is actually an epsilon):
  109.  
  110.        Macro:  QSXe= ]e=M]S De![
  111.                - --   - - - --
  112.  
  113.  
  114.  ---------------------------- B. DEFINING MACROS -----------------------------
  115.  
  116.  
  117.      To DEFINE a macro, type Esc[.  Macros execute EXACTLY as though you had 
  118.  typed the given keys yourself; this means that every keystroke, including 
  119.  answers to prompts, [Enter]s, and so on, must be properly included, so plan 
  120.  ahead carefully, with pen and paper if necessary.
  121.      Any PC keys can be entered at this prompt; a few, like arrow keys, will 
  122.  display with a recognizable symbol, but most (PgUp, etc) will simply display 
  123.  as a highlighted asterisk "*".  (VINST is capable of displaying the full 
  124.  keynames, if you create or display macros with it instead.)  Even MenuBar 
  125.  selections (except {User:}) can be used in macros, with the ^[Esc] command 
  126.  (see MENUBARS).
  127.  
  128.      Press ^[Break] to abandon the definition; once you press [Enter] to 
  129.  complete it, you will be asked whether you want to Use it immediately, or 
  130.  Store it (on storing, see ASSIGNING MACROS TO KEYS).  If you're going to use 
  131.  it now, you need to decide whether you want the macro to repeat (and if so, 
  132.  how many times), and whether you want to watch it happen or not:
  133.             VDE asks "Make Quiet, No-repeat, Both?"  Reply "Q" for 
  134.          Quiet (fast) operation, or press [Enter] for visible 
  135.          (slower) execution.  (The "N" option is intended for 
  136.          storing to keys, but can also be typed here to skip the 
  137.          next question.)
  138.             VDE asks "Repeat count?"  Type the number of times to 
  139.          execute (0-254), or just [Enter] for 1; or "*" to repeat 
  140.          indefinitely.
  141.  
  142.      When a macro is executing, the "!" flag appears in the header; normally, 
  143.  you can also see its effects as it proceeds.  You can cancel it at any time 
  144.  by pressing [Esc].  If you chose to speed up macro execution by specifying 
  145.  "Q"uiet mode, only the header will be updated as the macro runs.  (Don't do 
  146.  this if the macro uses any commands that require user input -- the necessary 
  147.  prompt would not display, and the macro would just appear to have stalled.)
  148.      By default, macros will stop automatically if an error condition occurs, 
  149.  in which case the error message will display briefly; or if the cursor 
  150.  attempts to move past the top or end of the file, in which case no error 
  151.  displays.  (See also ERROR HANDLING.)  Thus some macros will halt on their 
  152.  own when they reach the end of a file; others may have to be terminated 
  153.  manually, by pressing [Esc].
  154.      Once defined, a macro can be recovered by typing ^R to replay it at the 
  155.  Esc[ prompt, so that you can choose to Use it again, or Store it if you did 
  156.  not previously do so.
  157.      ^F, when entered as part of an input string, normally inserts the name of 
  158.  the current file (see PROMPTS).  In a macro definition, it remains an ^F, 
  159.  expanded to the current filename only when the macro actually executes.  This 
  160.  can be useful to refer to the current file when running compilers and file 
  161.  utilities.  Thus, if you define the macro
  162.                      AltR compile_^F_/g_/r1 [Enter] [Esc]
  163.  the ^F embedded in the string will be expanded, so that the DOS command 
  164.  executed by AltR when the macro is invoked will actually be something like
  165.                      compile C:\PGM\MYPROG.C /g /r1.
  166.  
  167.  
  168.      EXAMPLES OF ^P NESTING.  Note that in some situations, the use of ^P as a 
  169.  prefix for control keys at the macro definition prompt becomes nested.  
  170.  Suppose you want to define a macro containing the word "counterrevolutionary" 
  171.  with "counter" italicized.  The keystrokes you would use yourself are:
  172.                      ^P^Ycounter^P^Yrevolutionary
  173.  but to get these into a macro definition, you must type ^P TWICE to enter 
  174.  each ^P; ^P^Y by itself will enter only the ^Y into the macro, which would 
  175.  delete a line!  So you will type:
  176.               Macro: ...^PP^Ycounter^PP^Yrevolutionary...
  177.      Or, suppose you want to find the next occurrence of "Item" at the 
  178.  beginning of a line.  The actual keystrokes needed are:
  179.                      ^QF^MItem^[Enter]
  180.  (Note the use of ^[Enter] instead of [Enter] to avoid the Options prompt.)  
  181.  But to enter this as part of a macro definition, you will have to type:
  182.               Macro: ...^QF^MItem^P^[Enter]...
  183.      Failure to nest ^P prefixes properly is one of the most common causes of 
  184.  unexpected macro behavior.
  185.  
  186.      TECHNICAL NOTE: Ordinarily macros are completely self-contained, and 
  187.  NEVER request input from the keyboard while executing (unless the input pause 
  188.  commands Esc? or Esc: are used).  Confirmation prompts like "Abandon changes 
  189.  (Y/N)?", which may or may not pop up in normal usage of commands affecting 
  190.  disk files, NEVER occur when a macro is running, so you should never try to 
  191.  include a confirming "Y".  But there is one exception: using AltR to run 
  192.  another program (or DOS shell) from a macro is tricky.  Any input requested 
  193.  by the program or shell must be typed by you -- it cannot be included in the 
  194.  macro.  VDE resumes control only when the program or shell terminates; if the 
  195.  macro continues, its next keystroke must be the [Esc] required to return to 
  196.  editing.
  197.  
  198.  
  199.  --------------------------- C. RECORDING MACROS -----------------------------
  200.  
  201.  
  202.      As an alternative to composing macros and using the Esc[ command to 
  203.  define them, you can simply record a macro as you go about a task.  The main 
  204.  advantages are that you can see the effects as you go, and none of the 
  205.  additional ^P keystrokes sometimes necessary for entering commands at the 
  206.  macro definition prompt will be needed.  (On the other hand, a recorded macro 
  207.  must be a simple series of keystrokes; it cannot contain programming commands 
  208.  like jumps and tests.)
  209.  
  210.      Just press Esc" to activate recording; type away; and press Esc" again to 
  211.  conclude.  You will then be asked whether to use or store the macro you have 
  212.  created, just as if you had entered the macro at the Esc[ prompt.
  213.      While recording, a quote mark (") will be visible in the upper right 
  214.  (prefix) area of the header.  If you make a mistake, use Esc" again to stop 
  215.  recording, press [Esc] at the prompt to quit, and start over.  If anything 
  216.  you do while recording results in an error condition, recording will be 
  217.  canceled, and the quote will disappear from the header.
  218.  
  219.      NOTES: Because Function key commands (and also the {User:} MenuBar) use 
  220.  the same internal processes as macros, they cannot be used while macro 
  221.  recording is in progress.  Any other keystrokes can be recorded, including 
  222.  all other MenuBar selections.  Although they may not always be usefully 
  223.  precise, even mouse movements can be recorded as part of a macro, because 
  224.  they are simulated internally as sequences of arrow keys.
  225.  
  226.  
  227.  ----------------------- D. ASSIGNING MACROS TO KEYS -------------------------
  228.  
  229.  
  230.      Up to 48 macros can be assigned to function keys; they can then be 
  231.  recalled and used with one keystroke.  Each PC function key can be used alone 
  232.  or with Shift, Ctrl, or Alt, to produce:
  233.                     [F1]...[F10]  =  F1....F10 in VDE notation
  234.               Shift-[F1]...[F10]  =  !F1..!F10
  235.                Ctrl-[F1]...[F10]  =  ^F1..^F10
  236.                 Alt-[F1]...[F10]  =  @F1..@F10
  237.  And, if you have an Enhanced (101-key) AT keyboard, you will also have at 
  238.  your disposal F11 and F12 in the same four combinations.  VDE comes with [F1] 
  239.  set as "Help" (^J) and [F10] as "Menu" (^Esc), but this can be changed.
  240.  
  241.      If you find function keys difficult to remember, you can also assign a 
  242.  mnemonic letter or digit (alias) to invoke a definition with the [Esc] key; 
  243.  thus, if your Address is on [^F3], you could also call it up with EscA.
  244.  
  245.      The Esc[ command (see MACRO DEFINITION) gives the option of Storing the 
  246.  macro definition to any function key, so that the macro can later be executed 
  247.  simply by pressing that key.  If you choose "Store",
  248.             VDE asks "Make Quiet, No-repeat, Both:".  Reply "Q" for 
  249.          a key that executes in Quiet (fast) mode; "N" for a key 
  250.          that runs once, without asking for a repeat count; or "B" 
  251.          for both of these.  Press [Enter] instead for a key that 
  252.          executes just like the "Use macro" option, visibly, asking 
  253.          for a repeat count first.
  254.             VDE asks "Store to key:".  Press the desired function 
  255.          key, from [F1] to [@F12].
  256.             VDE asks "Esc key:".  If desired, press a letter or 
  257.          digit, which can then also be used with [Esc] to invoke 
  258.          this key.
  259.             VDE asks "Label?"  Enter a label, up to 7 characters, 
  260.          for the key label line (see FUNCTION KEY LABELS).
  261.  
  262.      Don't choose "Q"uiet (or "B"oth) for a key that will request input from 
  263.  you.  There are about 2000 bytes of storage available for all 48 keys, and a 
  264.  125 byte limit [in VDE; VINST can accept 253] for any one key.  You can 
  265.  delete a key definition by entering a null definition (Esc[, [Enter]) and 
  266.  storing it to the key.  Pressing an undefined key gives an error.
  267.      Keys defined while editing in VDE last only during the current editing 
  268.  session.  [To add a function key permanently to VDE.EXE, use VINST: either 
  269.  enter it again in VINST, or write it to a file and read the file into VINST 
  270.  -- see DEFAULT FUNCTION KEYS and DATA FILES.]
  271.  
  272.  
  273.  --------------------------- E. MACRO PROGRAMMING ----------------------------
  274.  
  275.  
  276.      "Macro programming" refers to a group of VDE commands that operate only 
  277.  within a macro definition, and give you conditional control over the 
  278.  execution of a macro.  Thus, instead of simply running straight through a 
  279.  sequence of keystrokes, a macro can be constructed very much like a computer 
  280.  program, with conditional or unconditional jumps from one part of the macro 
  281.  to another, giving great flexibility and power.  Here is a brief introduction 
  282.  to the range of macro programming commands.
  283.  
  284.      Jumps require "labels" to identify where to jump to: a macro label 
  285.  consists of [Esc] followed by a letter A-Z or digit 0-9.  If you typed this 
  286.  from the keyboard, it would be interpreted as an attempt to invoke a function 
  287.  key definition by an alias (see FUNCTION KEYS) -- but a macro can't do this, 
  288.  so EscA simply marks a location in the macro.
  289.  
  290.      Esc! is the unconditional jump instruction.  Followed by A-Z or 0-9, it 
  291.  causes execution of the macro to transfer to the command following that 
  292.  label, instead of simply continuing as usual to the next command.  So, for 
  293.  example, Esc!1 jumps to the label Esc1.  Thus the macro:
  294.  
  295.               This_is_ Esc!1 not_ Esc1 a_silly_macro.
  296.  
  297.  would produce the text "This is a silly macro."  In contrast, the macro:
  298.  
  299.               This_is_ Esc1 not_ Esc!1 a_silly_macro.
  300.  
  301.  would produce "This is not not not not not not not not not....", continuing 
  302.  indefinitely until you press [Esc] to abort it.  (This is an example of what 
  303.  programmers call an "infinite loop" -- occasionally useful, but generally an 
  304.  unfortunate error!)
  305.      There are also two special predefined "labels": "[" indicates the 
  306.  beginning of the macro, and "]" the end.  Thus Esc![ can be used to repeat 
  307.  the macro from the start, and Esc!] can be used to terminate it from any 
  308.  point.
  309.  
  310.      Several commands allow the use of a counter variable.  Esc() sets the 
  311.  value: for example, Esc(0) initializes it to zero.  The Esc+ command simply 
  312.  increments the value; Esc- (minus) is a conditional jump, decrementing the 
  313.  value, then jumping if it is zero to the specified label.  (In addition to a 
  314.  label 0-Z, you may use "[" or "]", or "@" to avoid jumping entirely.)  
  315.  Examples: Esc-] decrements the counter, jumping to the end (exiting) if it 
  316.  reaches zero; Esc-@ simply decrements it, with no jump.  Thus the macro:
  317.  
  318.               This_is_a_ Esc(3) EscL silly_ Esc-X Esc!L EscX macro.
  319.  
  320.  will produce the text "This is a silly silly silly macro."
  321.  
  322.      Conditional jumps, or tests, are performed by Esc= and Esc~.  Followed by 
  323.  a character, then a label, they are conditional jumps: they jump IF the text 
  324.  character at the cursor does (or for "~", does NOT) match the one specified.  
  325.  Examples: Esc~_2 jumps to label 2 if the cursor character is NOT a space; 
  326.  Esc=^M] jumps to the end (terminates) if the cursor character is a CR (^M).
  327.      Similarly, Esc< and Esc> test the cursor character's ASCII value and act 
  328.  accordingly: thus Esc<A2 jumps to label 2 if the cursor character value is 
  329.  less than ASCII "A" (41 hex), etc.
  330.  
  331.      The test commands (Esc=,~,<,>) can also be used in a second way, as self- 
  332.  contained search loops.  If instead of a label you use the character ">" or 
  333.  "<", the command will move the cursor right (or for "<", left) as long as the 
  334.  character at the cursor does (or for "~", does NOT) match the one specified.  
  335.  Example: Esc=_> moves right as long as the current character is a space (so 
  336.  it stops on the first NONspace).  Of course you could have done the same 
  337.  thing by programming an actual loop, with labels and a test and a right arrow 
  338.  command:
  339.               Esc1 Esc~_2 ^D Esc!1 Esc2
  340.  
  341.  but Esc=_> is simpler and more convenient.
  342.  
  343.       It is possible for one macro to chain (jump) to, or call, another macro.  
  344.  This can permit construction of a single macro longer than the usual maximum 
  345.  size; also, it often simply allows you to organize macros more efficiently 
  346.  and conserve definition space.  Esc&, followed by a key identification like 
  347.  "!F1", is used to chain to another key; the macro terminates when that key 
  348.  finishes.  Esc&& works similarly, but calls the other key, so that when it 
  349.  finishes, control returns to the original macro at the point following the 
  350.  Esc&& command.
  351.  
  352.  
  353.  ----------------------- F. EXAMPLES OF USEFUL MACROS ------------------------
  354.  
  355.  
  356.      Remember that macro examples are given as they function, NOT including 
  357.  the occasional ^P prefix you will need to enter certain control codes like 
  358.  ^M; and that while keystrokes are often separated by spaces for clarity, the 
  359.  underline symbol "_" is used to represent an actual space that you must type.
  360.      Several of the macro definitions in this section are included in the 
  361.  macro definition file EXAMPLES.VDK, which can be loaded with AltU.  (For 
  362.  details, see DEFAULT FUNCTION KEYS in VINST.REF.)
  363.  
  364.  
  365.                             SIMPLE MACRO EXAMPLES
  366.  
  367.      1. At its simplest, a function key is a way to reproduce keystrokes.  
  368.  Thus, if you're writing a document that will refer to "World Wide Widgets 
  369.  Ltd. (N.A.)" dozens of times, it will be easier (and cause fewer typos) if 
  370.  you define this phrase as a macro and assign it to a function key like [F3].
  371.  
  372.      2. The macro repeat count is an easy way to repeat VDE commands.  Suppose 
  373.  you have a horizontal bar installed as graphic character "Y", and you need to 
  374.  enter a line of 70 of them.  You could press AltG, then Y, 70 times... or you 
  375.  could define the macro:          AltG Y
  376.  and then Use it with a repeat count of 70.
  377.      Similarly, to reformat an entire file, go to the top if necessary, then 
  378.  define a macro as just:          ^B
  379.  Specify Quiet and indefinite repeat as options ("Q,*").  It will stop when it 
  380.  reaches the end of the file.
  381.  
  382.      3. To view a file by scrolling slowly through it, use the macro:
  383.                           Esc; ^Z   or    Esc; ^C
  384.  This pauses, then scrolls down (a line at a time with ^Z, a screen at a time 
  385.  with ^C).  Don't make it Quiet, just use a repeat count of "*".  Press [Esc] 
  386.  when you want to stop.
  387.  
  388.      4. This macro, with repeat count "*", would take all phrases in square 
  389.  brackets "[]" found in a file, and make a list of them in a second file being 
  390.  edited concurrently:
  391.      ^QR ^QF[^[Enter] ^G ^KB ^QF]^[Enter] ^G ^KK AltC AltN AltP [Enter] AltB
  392.  
  393.  
  394.                          SIMPLE FUNCTION KEY EXAMPLES
  395.  
  396.      1. This macro, which could be stored as No-repeat on a function key, re- 
  397.  loads the current file, eliminating any changes made since it was last saved:
  398.                                ^KL ^F [Enter]
  399.  
  400.      2. A function key defined as ^QR ^N AltD ^OF would place the current date 
  401.  at the top right of a letter.  Many VDE users set up a function key to 
  402.  produce a personalized letterhead: for example, the macro
  403.             ^N John_Doe ^OC ^N 123_Main_St ^OC ^N City,_State ^OC
  404.  will insert that three-line address, neatly centered.  You can add print 
  405.  effects (bold, italic) to suit your taste.  For a solid line separating this 
  406.  from the body of the letter, try adding onto the end:  ^N ^PS ^OF ^E ^PS ^X
  407.  
  408.      3. Function keys can be used to create powerful new commands, for 
  409.  example: ^D ^A ^KB ^F ^KK marks the current word as a block.  And, similarly, 
  410.  ^QS ^KB ^X ^KK marks the current line as a block.
  411.  
  412.  
  413.                           MACRO PROGRAMMING EXAMPLES
  414.  
  415.      1. This macro moves to the start of the current paragraph:
  416.                         ^QS ^S^S Esc=_[ ^D^D
  417.  Like the rest of the examples in this section, it might best be stored Quiet, 
  418.  No-Repeat to a function key.
  419.  
  420.      2. Moving to the start of the current sentence is a bit more complicated, 
  421.  but here is a macro program to do it:
  422.     Esc~.1 ^S Esc1 Esc~.< ^D Esc=_2 Esc=^M2 ^S^S Esc!1 Esc2 ^D Esc=_2 Esc=^M2
  423.  You could explain this in programmer's pseudo-code as:
  424.               If not "." goto label1    ;move left if already on period
  425.               Move left
  426.      label1:  While not "." move left   ;move left to previous period
  427.               Move right                ;move right to following character
  428.               If " "  or ^M goto label2
  429.               Move left twice           ;skip over a period if it's not
  430.               Goto label1               ;  followed by a space or return
  431.      label2:  Move right                ;okay, now move right as long
  432.               If " " or ^M goto label2  ;  as you see a space or return
  433.               (all done)
  434.  
  435.      3. If you want to produce a "pure ASCII" file for software that can't 
  436.  accept control codes (other than CR,LF) or IBM graphics, here is a key 
  437.  definition that will filter these out before you save to disk (use filemodes 
  438.  /A,U,N):    Esc*f ^QR EscB Esc>~X Esc=^MN Esc<_X EscN ^D Esc!B EscX ^G Esc!B
  439.  
  440.      4. This macro moves the cursor to the center of the current line; note 
  441.  how the counter variable is used to figure the line length, then move back 
  442.  only halfway:   ^QS Esc(0) Esc1 Esc+ ^D Esc~^M1 Esc2 Esc-] Esc-] ^S Esc!2
  443.  
  444.      5. Many programming languages use nested sets of parentheses, for example 
  445.  "{}" in C.  This macro, when the cursor is placed on an open bracket "{", 
  446.  will move ahead to find the closed bracket "}" that matches it:
  447.        Esc~{] Esc(0) Esc1 Esc~{2 Esc+ Esc!3 Esc2 Esc~}3 Esc-] Esc3 ^D Esc!1
  448.  
  449.  
  450.  ---------------------- G. ADDING FEATURES: MAIL MERGE -----------------------
  451.  
  452.  
  453.      There are many extra features commonly included in larger word processing 
  454.  packages which are not built into VDE.  But as the above examples have shown, 
  455.  macro programming and function keys actually allow you to develop your own 
  456.  custom editor commands, using the existing ones as building blocks.  This 
  457.  means that with macros you can often add features you need yourself, and 
  458.  moreover design them to work exactly the way you want!
  459.  
  460.      To demonstrate that this isn't really difficult at all, consider "Mail 
  461.  Merge": the automatic production of multiple copies of the same document, 
  462.  with occasional insertions at certain points taken from a data list.  The 
  463.  classic example is a form letter to be sent to dozens, or hundreds, of 
  464.  recipients on a mailing list.  Suppose we compose the text of our letter -- 
  465.  except that in place of a name (since they'll vary) we'll just type a 
  466.  variable name, say "@@N", instead, and in place of an address, the variable 
  467.  "@@A".  So the file might begin:
  468.                                              29 February 1993
  469.               @@N
  470.               @@A
  471.  
  472.               Dear @@N,
  473.  
  474.                    We are pleased to announce the opening of...
  475.  
  476.  And in another file we have our mailing list, possibly typed by hand, more 
  477.  likely generated by a database program.  Various formats are possible; let's 
  478.  suppose that each "entry" is a name and address, of varying numbers of lines, 
  479.  terminated by an empty line.  So the file might begin:
  480.  
  481.               C.J. Aubergine              <- first line of file
  482.               221-A Slumgullion Road
  483.               Hoagie, IL 63213
  484.                                           <- blank line after each entry
  485.               Margarita Empanada
  486.               P.O. Box 31722
  487.               Sopapilla, CA 91306
  488.  
  489.               Karl Hasenpfeffer
  490.               Schlagsahnestr. 11
  491.               D-1380 Rotkohl
  492.               GERMANY
  493.  
  494.      We would like to have a key like [F12] programmed so that you could just 
  495.  press it in order to print off a whole series of letters, one for each entry 
  496.  in the list, with the appropriate information in the header and salutation.  
  497.  You can probably see how you would go about the job yourself manually, though 
  498.  it would be incredibly tedious: find each "@@" variable in the letter file, 
  499.  switch to the data list, mark and cut the name (for @@N) or address (for 
  500.  @@N), paste it into the letter file in place of the variable name, print the 
  501.  letter when done, then start all over again with the second name...  Thus, 
  502.  one approach to creating a mail-merge macro would be to switch on macro 
  503.  recording while creating the first letter to print yourself -- ending your 
  504.  recorded key sequence by reloading the original letter with the variable 
  505.  names and advancing to the second entry in the list, ready to continue.  Then 
  506.  you could store the resulting macro to a key, and execute it repeatedly.
  507.  
  508.      Alternatively, you could plan everything out ahead of time and design a 
  509.  macro program containing appropriate labels and jumps to execute the entire 
  510.  process automatically.  The following macro will work properly with files as 
  511.  described above; just install it (No-repeat) on a function key.  Brief 
  512.  comments have been added for explanation.  Before using the macro as 
  513.  presented here, you must be editing the letter file (which must have been 
  514.  saved to disk), with the address list loaded as a second file, and the cursor 
  515.  must be at the top of both files.  If you want to test it out without wasting 
  516.  paper, use a spooler utility to redirect your printer output to a disk file, 
  517.  or substitute Esc; or Esc? for the ^KP[Enter] command so you can view each 
  518.  version of the letter on screen as it's finished.  It's rather striking how 
  519.  much can be accomplished with such a modest macro.
  520.  
  521.    Esc$3 ^QF@@^[Enter]           ;Find next variable, skip to print if none
  522.    Esc$$ ^D^D Esc=A1 Esc~N[      ;Was it @@A or @@N? (skip if neither)
  523.    AltN ^KB^QD^KK AltC           ;Request was for Name,
  524.    ^QS AltN Esc!2                ; so mark and cut first line of entry
  525.      Esc1                        ;  (always leaving cursor at start of entry)
  526.    AltN ^X^KB^QF^M^M^[Enter] ^KK ;Request was for Address,
  527.    AltC ^QB^E AltN               ; so mark and cut the rest of the entry
  528.      Esc2
  529.    ^A^G^G^G                      ;Back to the letter: delete variable name,
  530.    AltP Esc![                    ; paste in the data, and go on to next
  531.      Esc3
  532.    ^KP[Enter]                    ;Letter is ready, so print it
  533.    ^KL^F[Enter]                  ; and reload original copy with @@ variables
  534.    AltN ^QF^M^M^[Enter] ^D^D     ;Position to next entry in list
  535.    Esc<_]                        ;Quit if no more entries,
  536.    AltN Esc![                    ; otherwise do it all over again
  537.  
  538.      You will find this macro program available for use in the EXAMPLES.VDF 
  539.  file (see DEFAULT FUNCTION KEYS in VINST.REF).  This example has been kept 
  540.  very simple, to illustrate the basic approach; as an exercise, you might try 
  541.  modifying it to put only the first name in the letter salutation, or to use 
  542.  database lists in comma-delimited format, and so on.  You can tailor your own 
  543.  mail-merge feature to suit your requirements.
  544.  
  545.  
  546.  ============================ 9. MACRO REFERENCE =============================
  547.  
  548.  
  549.  AUTOEXEC MACRO -  VINST can designate one function key definition you create 
  550.     as "autoexec", meaning that this macro will execute automatically whenever 
  551.     you first enter VDE.  This feature can be used in a variety of ways, for 
  552.     example:
  553.               (1) You can use an autoexec macro to change defaults 
  554.          not available as VINST options.  (If you load multiple 
  555.          files, remember that some settings like margins are 
  556.          specific to each file, so only the first file will be 
  557.          affected.)
  558.               (2) You can turn VDE into a text modification engine 
  559.          by setting up a key definition (.VDF) file containing an 
  560.          autoexec macro program that alters the text in some way and 
  561.          then exits.  (Any .VDF file specified with a ";" on the 
  562.          command line is loaded before the autoexec process.)
  563.     See also SYNTAX, FUNCTION KEYS, DATA FILES.  Note: you cannot use a 
  564.     utility that stuffs input into the DOS keyboard buffer before running VDE, 
  565.     if an autoexec macro exists.
  566.  
  567.  CHAINING AND CALLING (Esc&,&&) - Esc&, followed by a key identification like 
  568.     "!F1", is used to "chain" (or jump) to another function key.  Use "!,^,@" 
  569.     for Shift, Ctrl, Alt; and after the "F", a single digit "1"-"9", or "A"- 
  570.     "C" for 10-12.  ("0" is also accepted for F10.)  Examples: Esc&F2 chains 
  571.     to F2; Esc&^FB chains to Ctrl-F11.
  572.          Esc&& works similarly but "calls" the other key, returning when it 
  573.     finishes.  Calls may be nested at most 4 deep.
  574.  
  575.  COUNTER VARIABLE (Esc(),+,-) - Esc(n) sets the counter value to "n".  Esc+ 
  576.     simply increments the value; Esc- (minus) is a conditional jump, decre- 
  577.     menting the counter, then jumping if it is zero to a specified label.  
  578.     (Besides a label 0-Z, you can use "[" or "]" for the start or end, or "@" 
  579.     to decrement without jumping at all.)
  580.          The counter can run "negative", though it is actually an unsigned 
  581.     integer: if you decrement it from 0, it becomes 65535 (effectively -1); if 
  582.     you increment it from 65535, it becomes 0.
  583.  
  584.  DEFINE OR RECORD MACRO (Esc[,") - To define a macro, type Esc[.  You will be 
  585.     asked for the macro definition; for full instructions, see DEFINING 
  586.     MACROS.  Once defined, you will have the option to Use the macro 
  587.     immediately or to Store it to a key.
  588.          Even if you did not Store your last macro when you originally defined 
  589.     it, you can still re-Use (or Store) it at a later time by using ^R 
  590.     (replay) at the Esc[ prompt.
  591.          As an alternative to composing macros and using the Esc[ command to 
  592.     type them in, you can simply record a macro as you go about a task.  Press 
  593.     Esc" to activate recording; type away; then press Esc" again to conclude.  
  594.     While recording, a quote mark (") will be visible in the upper right 
  595.     (prefix) area of the header.  If you make an error while recording, use 
  596.     Esc" to stop recording, press [Esc] at the prompt to quit, and start over.
  597.  
  598.  ERROR HANDLING (Esc$) - Esc$ can specify a label where macro execution should 
  599.     continue if an error occurs (normally, execution would terminate).  Thus, 
  600.     after the command Esc$E, any command resulting in an error (like "Not 
  601.     Found") will cause a jump to label E, ignoring the error.  You can also 
  602.     use the special characters "[","]" to jump to the beginning or end of the 
  603.     macro, or "@" to simply ignore errors, not jumping anywhere, or "$" to 
  604.     return to the normal default of halting on any error.
  605.  
  606.  FUNCTION KEYS ([F1]...[F12], EscA-Z,0-9) -  Macros can be assigned to 
  607.     function keys, either alone or with Shift, Ctrl, or Alt (!,^,@) for a 
  608.     total of 48 function keys.  These keys can be labeled for easy remembering 
  609.     (see FUNCTION KEY LABELS), or you can assign a letter or digit to invoke a 
  610.     definition with the [Esc] key; thus, if your Address is on [^F3], you 
  611.     could also call it up with (say) EscA.  For detailed instructions, see 
  612.     ASSIGNING MACROS TO KEYS.
  613.          (Note: users of VDE prior to version 1.7 will recall EscA-Z as a 
  614.     separately definable set of MACRO KEYS; they now function simply as 
  615.     mnemonic aliases for function keys.)
  616.  
  617.  FUNCTION KEY LABELS (^OU) - To help you remember the purpose of your function 
  618.     key definitions, the ^OU command toggles the display of a label line at 
  619.     the bottom of the screen.  When a key is defined, its number will appear 
  620.     on the label line, followed by the label (if any) entered when the key was 
  621.     stored.
  622.          The label display is sensitive to keyboard shift status; if you press 
  623.     and hold Shift, Ctrl, or Alt for a moment, the labels will change to show 
  624.     those for the shifted function keys.
  625.          On 80-column screens, 10 labels are visible; in 40-column mode, 5.  
  626.     Labels for the F11, F12 keys only appear on screens of 96 or more columns.
  627.  
  628.  KEY DEFINITION FILES (AltU) -  These files save function key definitions and 
  629.     labels, and should be given a file type of ".VDF".  You can load such a 
  630.     file, along with your text file(s) to edit, from the command line (see 
  631.     SYNTAX).
  632.          AltU can be used while editing: it will ask whether you want to 
  633.     "L"oad or "S"ave such a file, then prompt for the name of the file.  If 
  634.     you load a .VDF file, those definitions will replace any previous ones.  
  635.     If you save, the current definitions will be written to the file.  [.VDF 
  636.     files can also be created or installed as defaults in your copy of VDE, 
  637.     using VINST.]
  638.  
  639.  LABELS AND JUMPS (Esc0..Z,Esc!) - Esc0..Z, when placed in a macro, function 
  640.     simply as local "labels" 0..Z.  They have no effect, but can be "jumped" 
  641.     to by other commands.
  642.          Esc! followed by 0..9,A..Z is a "jump" instruction, causing macro 
  643.     execution to resume with the command following that label.  Example: Esc!2 
  644.     jumps to label 2.  As two special cases, Esc![ jumps to the beginning of 
  645.     the macro, and Esc!] jumps to the end (exits).
  646.          Note that Labels can also be referenced by the test commands, which 
  647.     perform conditional jumps (see TESTS AND LOOPS).
  648.  
  649.  PAUSE (Esc;,Esc?,Esc:) - Esc; gives a brief pause before macro execution 
  650.     continues, so the user can see what's happening on screen.  Use two or 
  651.     more to get a longer pause.
  652.          Esc? accepts text or commands from the keyboard during macro 
  653.     execution.  The header's "!" flag turns into "?" when user input is 
  654.     expected.  Anything except macro and function key commands may be used.  
  655.     [Esc] terminates input, returning control to the macro.  ^[Break] aborts.
  656.          Esc: makes the following command take its input from the keyboard.  
  657.     The macro resumes when that command is completed.  Examples: Esc:^QF 
  658.     allows you to type in the string to find; Esc:Esc! actually lets you type 
  659.     the label to jump to.
  660.  
  661.  TESTS AND LOOPS (Esc=,~,<,>) - Esc= and Esc~ perform tests on the character 
  662.     at the current cursor position.  There are two ways to use them:
  663.              (1) Followed by a character, then a label (0-Z,[,]), 
  664.          they are conditional jumps: they jump to the label IF the 
  665.          cursor character does (or for "~", does NOT) match the one 
  666.          specified.
  667.              (2) Followed by a character, then ">" or "<", they are 
  668.          search loops.  They will continue to move the cursor right 
  669.          or left as long as the cursor character does (or for "~", 
  670.          does NOT) match.
  671.          Similarly, Esc< and Esc> test the cursor character's ASCII value and 
  672.     act according to whether it is less, or greater, than the specified value.  
  673.     (See ASCII table in VINST.REF)
  674.          (Note: place and block markers, since they are not part of the file 
  675.     text, will fail any test.  If you need to check for their presence, you 
  676.     can use Esc<^@ [that's 00 hex, entered as ^P@] since no actual character 
  677.     could be <0 and fail this test.)
  678.  
  679.  TOGGLE CONTROL (Esc*) -  "Toggle" commands can create difficulties when used 
  680.     in macro and function keys: ^V, for example, toggles insert mode.  But 
  681.     when you plan a function key, you don't necessarily know how Insert will 
  682.     be set when the key is used!  So if you use ^V in the macro, you don't 
  683.     know whether you just turned it off or on; you might be overstriking or 
  684.     inserting, and can't tell.
  685.          The Esc* command provides a solution, by letting a macro specify an 
  686.     exact state for each toggle.  Esc* must be followed by a LETTER to 
  687.     identify a toggle, UPPERcase to turn it ON or LOWERcase to turn it OFF.  
  688.     (Insert and Justify each have a third state, as well.)  For example, Esc*i 
  689.     will set INSERT OFF, regardless of its previous state.  The toggles are:
  690.               Autoindent     (^OA)  'a'=off  'A'=on
  691.               Column block  (^KN,I) 'c'=off  'C'=on  'O'=replace
  692.               Doublespace    (^OS)  'd'=off  'D'=on
  693.               auto Format    (^OM)  'f'=off  'F'=on
  694.               Hyphenation    (^OH)  'h'=off  'H'=on
  695.               Insert         (^V)   'i'=off  'I'=on  'W'=word
  696.               Justification  (^OJ)  'j'=off  'J'=on  'R'=remove
  697.               Proportional   (^OK)  'p'=off  'P'=on
  698.              [Single line reformat] 's'=off  'S'=on
  699.               Varitab        (^OV)  'v'=off  'V'=on
  700.               margin release (^OX)  'x'=off  'X'=on
  701.               hard reformat  (^OY)  'y'=off  'Y'=on
  702.  
  703.  
  704.  =============================[end VMACRO.REF]================================
  705.